#!/bin/bash
docker_image_name=$1
rm -fr opencloudos-rootfs/
docker_path=$(pwd) 
mkdir opencloudos-rootfs  
rpm --root $docker_path/opencloudos-rootfs --initdb 

dnf --installroot=$docker_path/opencloudos-rootfs/ --disablerepo="*" URL \
--nogpgcheck --releasever=1 -y install dnf yum rootfiles vim-minimal system-release --setopt=install_weak_deps=False

cd $docker_path/opencloudos-rootfs/usr/share/locale&&find * | grep -v '\(en_*\|zh_*\)' | xargs rm -fr
cd $docker_path/opencloudos-rootfs/usr/lib/locale&&find * | grep -v '\(C.utf8\|en_US.utf8\|zh_CN*\)' | xargs rm -fr
cd $docker_path/opencloudos-rootfs
rm -r var/log/*
rm -r var/cache/dnf/*

tar -cf ../$docker_image_name.tar *
